﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MvcWiki.Repository;
using MvcWiki.Markup;

namespace MvcWiki.Repository.FileSystem
{
    public class WikiFileSystemRepositoryFactory : IWikiRepositoryFactory
    {
        IUnitOfWork UnitOfWork;
        IWikiPageRepository WikiPageRepository;
        IWikiNamespaceRepository WikiNamespaceRepository;

        public WikiFileSystemRepositoryFactory(IWikiMarkupProvider wikiMarkupProvider, IUnitOfWork unitOfWork, string dataPath)
        {
            this.UnitOfWork = unitOfWork;

            var fileSystem = new FileSystemWrapper();

            WikiPageRepository = new WikiPageFileSystemRepository(this, this.UnitOfWork, dataPath, fileSystem);

            WikiNamespaceRepository = new WikiNamespaceFileSystemRepository(this, wikiMarkupProvider, this.UnitOfWork, dataPath, fileSystem);
        }

        public IWikiPageRepository GetWikiPageRepository()
        {
            return WikiPageRepository;
        }

        public IWikiNamespaceRepository GetWikiNamespaceRepository()
        {
            return WikiNamespaceRepository;
        }
    }
}
